# from fastapi import (
#     Depends,
#     HTTPException,
# )
# from fastapi.security import OAuth2PasswordBearer
# from jose import (
#     JWTError,
#     jwt,
# )
# from motor.motor_asyncio import AsyncIOMotorClient
# from pymongo.database import Database
# from starlette import schemas
#
# from config import settings
#
#
# oauth2_scheme = OAuth2PasswordBearer(tokenUrl="token")
#
# client = AsyncIOMotorClient(settings.MONGODB.URI)
# database = client.your_database_name


# async def get_current_user(
#     token: str = Depends(oauth2_scheme),
#     db: Database = Depends(get_database),
# ) -> dict:
#     credentials_exception = HTTPException(
#         status_code=401,
#         detail="Could not validate credentials",
#         headers={"WWW-Authenticate": "Bearer"},
#     )
#     try:
#         payload = jwt.decode(token, settings.SECURITY.SECRET_KEY, algorithms=[settings.SECURITY.ALGORITHM])
#         username: str = payload.get("sub")
#         token_data = schemas.TokenData(username=username)
#     except JWTError:
#         raise credentials_exception
#     user = await db.users.find_one({"username": token_data.username})
#     if user is None:
#         raise credentials_exception
#     return user
